﻿using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Project_Flight;
using Sybase.Mobile;
using Sybase.Persistence;
using Sybase.Collections;

namespace Project_Flight
{
    public partial class FormCustomerDetail : Form
    {
        MBO_Customer customer;
        public FormCustomerDetail()
        {
            InitializeComponent();
        }

        private void submit_Click(object sender, EventArgs e)
        {
            String number = Program.getCustomer();
            ZBAPI_FLCUST_CHANGE_CUSTOMER_DATA data = new ZBAPI_FLCUST_CHANGE_CUSTOMER_DATA();

            data.CUSTNAME = textBox2.Text;
            data.CITY = textBox3.Text;
            ZBAPI_FLCUST_CHANGE_CUSTOMER_DATA_X datax = new ZBAPI_FLCUST_CHANGE_CUSTOMER_DATA_X();
            datax.CUSTNAME = "X";
            datax.CITY = "X";
           // BAPI_FLCUST_CHANGE_RETURN return1 = new BAPI_FLCUST_CHANGE_RETURN();
            customer.ChangeCustomer(datax, data,number );
            customer.Save();
            customer.SubmitPending();
            FlightDB.Synchronize();
            MessageBox.Show("Done");

            //ISynchronizationGroup sg = SUP101DB.GetSynchronizationGroup("default");
            //GenericList<ISynchronizationGroup> syncGroups = new GenericList<ISynchronizationGroup>();
            //syncGroups.Add(sg);
            //SUP101DB.BeginSynchronize(syncGroups, "");

            Program.getForm1().Visible = true;
            //Program.getForm1().RefreshListItem(thisCustomer.SurrogateKey);
            Program.getForm2().Visible = false;
        }
        private void AddDataToForm()
        {
           
            long id = Program.getSk();
            customer = MBO_Customer.Find(id);
            textBox1.Text = customer.CUSTOMERID;
            textBox2.Text = customer.CUSTNAME;
            textBox3.Text = customer.CITY;
        }
        private void Customer_Details_Load(object sender, EventArgs e)
        {
            AddDataToForm();
        }
        private void Customer_Details_paint(object sender, PaintEventArgs e)
        {
            AddDataToForm();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            FormCustomerDetail n = new FormCustomerDetail();
            long counter = 1;
            long next = Program.getSk() + 1L ;
            
            Program.setSk(next);
            n.Visible = true;
            this.Visible = false;
           

        }




    }
}